/*
 * Copyright (c) 2023-2023 elsfs Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.elsfs.cloud.system.api.entity;

import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.elsfs.cloud.api.validation.group.GroupValidation;
import org.elsfs.cloud.common.annotations.Spell;
import org.elsfs.cloud.common.core.entity.BaseTreeEntity;

/**
 * 部门
 *
 * @author zeng
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ColumnWidth(20)
public class SysDept extends BaseTreeEntity<SysDept, String> {
  @TableId
  @ExcelProperty(value = "部门ID")
  @NotBlank(
      message = "部门ID不能为空",
      groups = {GroupValidation.Edit.class})
  private String deptId;

  /** 上级部门 */
  @NotBlank(
      message = "上级部门不能为空",
      groups = {GroupValidation.Add.class, GroupValidation.Edit.class})
  @ExcelProperty(value = "上级部门")
  private String parentId;

  /** 部门电话 */
  @ExcelProperty(value = "部门电话")
  @TableField(whereStrategy = FieldStrategy.NOT_EMPTY)
  private String mobile;

  /** 部门地址 */
  @ExcelProperty(value = "部门地址")
  @TableField(whereStrategy = FieldStrategy.NOT_EMPTY)
  private String address;

  /** 部门名称 */
  @NotBlank(
      message = "部门名称不能为空",
      groups = {GroupValidation.Add.class, GroupValidation.Edit.class})
  @ExcelProperty(value = "部门名称")
  @TableField(condition = SqlCondition.LIKE)
  @Spell
  private String deptName;

  /** 部门编码 */
  @ExcelProperty(value = "部门编码")
  @TableField(whereStrategy = FieldStrategy.NOT_EMPTY)
  private String orgCode;

  /** 部门类型 */
  @ExcelProperty(value = "部门类型")
  private Integer orgCategory;

  /** 排序 */
  @ExcelProperty(value = "排序")
  @NotNull(
      message = "排序不能为空",
      groups = {GroupValidation.Add.class, GroupValidation.Edit.class})
  private Integer orderNo;

  /** 状态 */
  @ExcelProperty(value = "状态")
  @TableField(whereStrategy = FieldStrategy.NOT_EMPTY)
  private String status;

  /** 备注 */
  @TableField(condition = SqlCondition.LIKE)
  @ExcelProperty(value = "备注")
  private String deptDesc;

  @Override
  public String getId() {
    return deptId;
  }
}
